<%= render layout: "layouts/decidim/shared/layout_item" do %>

  <%= render partial: "schema_org_event_meeting" %>

  <section class="layout-main__section layout-main__heading">
      <h1 class="h2 decorator"><%= present(meeting).title(html_escape: true ) %></h1>
      <%= cell "decidim/meetings/dates_and_map", meeting %>
      <div class="block md:hidden">
        <%= render partial: "meeting_aside", locals: { hide_modal: true } %>
      </div>

      <%= render partial: "meeting_poll_actions", locals: { mobile: true } %>

    <% if meeting.private_meeting? || meeting.withdrawn? %>
      <div class="layout-author has_status">
        <% if meeting.private_meeting? %>
          <span class="<%= meeting_type_badge_css_class("private") %> label">
            <%= t("private_meeting", scope: "decidim.meetings.types") %>
          </span>
        <% end %>
        <% if meeting.private_meeting? and meeting.transparent? %>
          <span class="<%= meeting_type_badge_css_class("transparent") %> label">
            <%= t("transparent", scope: "decidim.meetings.types") %>
          </span>
        <% end %>
        <% if meeting.withdrawn? %>
          <span class="<%= meeting_type_badge_css_class("withdraw") %> label">
            <%= t("withdraw", scope: "decidim.meetings.types") %>
          </span>
        <% end %>
      </div>
    <% end %>

    <div class="layout-author <%= "has_status" if meeting.private_meeting? || meeting.withdrawn? %>">
      <div class="relative flex items-center justify-center w-full">
        <div class="w-10/12 flex items-center gap-4">
          <%= cell "decidim/author", author_presenter_for(meeting.author), from: meeting, context_actions: nil, layout: :compact %>
        </div>
        <%= render "decidim/shared/resource_actions", resource: meeting do %>
          <%= render "decidim/meetings/meetings/meeting_actions" %>
        <% end %>
      </div>
    </div>

  </section>
  <section class="layout-main__section">
    <div class="editor-content">
      <%= render_meeting_body(@meeting) %>
    </div>
  </section>

  <section class="layout-main__section">
    <% unless meeting.in_person? || meeting.withdrawn? %>
      <%= cell "decidim/meetings/online_meeting_link", meeting %>
    <% end %>
  </section>

  <%= cell "decidim/tab_panels", tab_panel_items %>

  <% if meeting.agenda.present? && meeting.agenda.visible? %>
    <section class="layout-main__section">
      <%= render "meeting_agenda" %>
    </section>
  <% end %>

  <% if meeting.closed? && meeting.closing_visible? %>
    <section class="layout-main__section">
      <%= render "meeting_minutes" %>
    </section>
  <% end %>

  <%= cell("decidim/tags", meeting) %>

  <section class="layout-main__section layout-main__buttons" data-buttons>
    <%= cell "decidim/comments_button", nil %>

    <div class="ml-auto lg:ml-0">
      <%= cell "decidim/share_widget", meeting %>
    </div>
  </section>

  <%= pad_iframe_for meeting %>

  <% content_for :aside do %>
    <div class="hidden md:block">
      <%= render partial: "meeting_aside" %>
    </div>
  <% end %>

  <% content_for :item_footer do %>
    <%= comments_for meeting %>
    <ul class="metadata__container layout-main__section" data-metadata-footer>
      <%= content_tag :li, resource_reference(meeting), class: "metadata__item" %>
      <%= content_tag :li, resource_version(meeting, versions_path: meeting_version_path(meeting, meeting.versions.count)), class: "metadata__item" %>
      <%= content_tag :li, link_to(t("add_to_calendar", scope: "decidim.meetings.meetings.calendar_modal"), nil, remote: true, data: { dialog_open: "calendarShare_#{meeting.id}" }), class: "metadata__item" %>
    </ul>
  <% end %>
<% end %>

<%= render partial: "add_to_calendar_modal", locals: { ics_url: calendar_meeting_url(meeting), google_url: google_calendar_event_url(meeting), id: meeting.id } %>
